package com.jyx.cloud.controller;

import com.jyx.cloud.entity.CommonResult;
import com.jyx.cloud.entity.Member;
import com.jyx.cloud.service.IMemberService;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RestController;

import javax.annotation.Resource;

/**
 * @author jyx
 * @version 1.0
 * @email jiangyongxing@myzczk.com
 * @company www.myzczk.com
 * @create-time 2020/5/27 17:12
 */

@RestController
@Slf4j
public class MemberController {

    @Resource
    private IMemberService memberService;
    @Value("${server.port}")
    private String serverPort;

    /**
     * 如果是封装类型，要家@RequestBody注解
     * @param id
     * @return
     */
    @GetMapping(value = "/member/get/{id}")
    public CommonResult<Member> getMember(@PathVariable("id") String id){
        log.info("参数id:"+id);
        Member member = memberService.getMemberById(id);
        log.info("查询结果："+member);
        return new CommonResult<Member>(200,"成功:"+serverPort,member);
    }

}
